package o;

import android.content.Context;
import android.os.Build.VERSION;
import androidx.annotation.NonNull;
import com.huawei.appgallery.packagemanager.api.bean.ManagerTask;
import java.util.ArrayList;
import java.util.List;
import o.bpc.c;

public class bom implements coi {
    private static bom ˎ;
    private final Context ˋ = ContentManager.getInstant().getContext();

    public static synchronized bom ॱ() {
        bom o_bom;
        synchronized (bom.class) {
            if (ˎ == null) {
                ˎ = new bom();
            }
            o_bom = ˎ;
        }
        return o_bom;
    }

    private bom() {
    }

    private void ˏ(@NonNull ManagerTask managerTask, long j, int i, int i2) {
        boc.ˎ.ˋ("InstallListener", "onInstallMessage, installId: " + j + ", type: " + i + ", installStatus: " + i2);
        bol ˋ = bor.ˎ().ˋ(j);
        if (ˋ != null) {
            if (VERSION.SDK_INT > 28 && ˋ.ʼ()) {
                ˏ(managerTask, ˋ, i, i2);
            }
            if (ˋ.ʻ() == 10 || ˋ.ʻ() == 11 || ˋ.ʻ() == 20) {
                ˊ(managerTask, ˋ, i, i2);
            }
            bor.ˎ().ˊ(ˋ.ˏ());
        }
    }

    private void ˊ(@NonNull ManagerTask managerTask, @NonNull bol o_bol, int i, int i2) {
        if (ccx.ॱ()) {
            cvt o_cgj = new cgj();
            o_cgj.ˋ(managerTask.packageName);
            o_cgj.ॱ(managerTask.versionCode);
            o_cgj.ˎ(i == 5 ? 0 : 1);
            o_cgj.ॱ(String.valueOf(i2));
            o_cgj.ˏ(1);
            o_cgj.ˎ(String.valueOf(managerTask.taskId));
            List arrayList = new ArrayList();
            bpc ˊॱ = o_bol.ˊॱ();
            if (ˊॱ == null) {
                boc.ˎ.ˊ("InstallListener", "Calling session.getInstallTaskBuilder() returns null.");
                return;
            }
            List ˋ = ˊॱ.ˋ();
            for (int i3 = 0; i3 < ˋ.size(); i3++) {
                c cVar = (c) ˋ.get(i3);
                if (!arrayList.contains(cVar.ॱ())) {
                    arrayList.add(cVar.ॱ());
                    o_cgj.ˊ(cVar.ॱ());
                    o_cgj.ˏ(cVar.ˏ());
                    boc.ˎ.ˋ("InstallListener", "Report install result: " + cVar.ॱ());
                    bqe.ˋ(o_cgj, new cgf(false));
                }
            }
            return;
        }
        boc.ˎ.ˏ("InstallListener", "No report installation results, because agreement was not signed.");
    }

    private void ˏ(@NonNull ManagerTask managerTask, @NonNull bol o_bol, int i, int i2) {
        bpq o_bpq = new bpq(this.ˋ, o_bol.ˋ());
        bqd ˋ = bpe.ˋ(o_bol, managerTask, i2);
        if (i == 5) {
            o_bpq.ˎ(o_bol.ˏ(), ˋ);
        } else if (i == 4) {
            o_bpq.ॱ(o_bol.ˏ(), ˋ);
        }
    }

    public void ॱ(ManagerTask managerTask, int i, int i2) {
    }

    public void ˋ(ManagerTask managerTask, int i, int i2) {
        if (managerTask == null) {
            return;
        }
        if (i == 4 || i == 5 || i == 9 || i == 10) {
            ˏ(managerTask, managerTask.taskId, i, i2);
            return;
        }
        boc.ˎ.ˋ("InstallListener", "install callback (ignore), installId: " + managerTask.taskId + ", type: " + i + ", installStatus: " + i2);
    }
}
